#引入生成随机数的模块
import random
#程序设定生成 1-20 之间的一个随机数，让用户猜
secretNum = random.randint(0,100)
i = 0
print("这是一个位于 1-20 之间的数")
while(True):

    i = i+1
    print("请输入猜测的数：")
    try:
        guess = int(input())
    except:
        print("输入的内容必须为整数！")
        continue

    if guess == 0:
        break
    if guess < secretNum:
        print("遗憾，太小啦")
    elif guess > secretNum:
        print("遗憾，太大啦")
    else:
        break

if(guess == secretNum):
    print(f"预测{i}次，你猜中了")
else:
    print("很遗憾，正确的答案应该是", str(secretNum))
